//将date转换成String
function SetTimeformate(newtime){
	   var d, s;                  
	   d = new Date();           
	   d.setTime(newtime);
	  if(window.navigator.userAgent.indexOf("Firefox")>=1){
		 s = (d.getYear()+1900)+"-"+(d.getMonth()+1)+"-"+d.getDate(); 
	  }else{
	     s = d.getYear()+"-"+(d.getMonth()+1)+"-"+d.getDate(); 
	  }
	   return(s);                 
}

/**
 * 将date转换成String
 * 如果date为null，显示指定的str字符串
 */
function SetTimeformate3(newtime, str){
	if (newtime == null || newtime == "") {
		return str;
	}
	var d, s;                  
	d = new Date();           
	d.setTime(newtime);
	if(window.navigator.userAgent.indexOf("Firefox")>=1){
		s = (d.getYear()+1900)+"-"+(d.getMonth()+1)+"-"+d.getDate(); 
	}else if(window.navigator.userAgent.indexOf("Chrome")>=1 || BrowserType().ie == 9.0){
		s = (d.getYear()+1900)+"-"+(d.getMonth()+1)+"-"+d.getDate(); 
	}else{
	    s = d.getYear()+"-"+(d.getMonth()+1)+"-"+d.getDate(); 
	}
	return(s);                 
}


//将date转换成String带小时 分
function SetTimeformate2(newtime){
	if(newtime==null){
		return "--";
	}
	  var d, s; 
	  var year; 
	  var month;
	  var daily; 
	  var houre;
	  var minute;            
	   d = new Date();           
	   d.setTime(newtime);
	  if(window.navigator.userAgent.indexOf("Firefox")>=1){
		 
		 year=d.getYear()+1900;
		 
		 if(d.getMonth()+1>0&&d.getMonth()+1<10){
		 month="-0"+(d.getMonth()+1);
		 }else{
		 month="-"+(d.getMonth()+1);
		 }
		 if(d.getDate()>0&&d.getDate()<10){
		 daily="-0"+d.getDate();
		 }else{
		 daily="-"+d.getDate();
		 }
		 
		}else{
		
		  year=d.getYear();
		 if(d.getMonth()+1>0&&d.getMonth()+1<10){
		 month="-0"+(d.getMonth()+1);
		 }else{
		 month="-"+(d.getMonth()+1);
		 }
		 if(d.getDate()>0&&d.getDate()<10){
		 daily="-0"+d.getDate();
		 }else{
		 daily="-"+d.getDate();
		 }
		}
	   s=year+month+daily;
	   hours=d.getHours();
	   if(hours>0&&hours<10){
	   	   hours="0"+hours;
	   }
	   minute=d.getMinutes();
	   if(minute>0&&minute<10){
	   	   minute="0"+minute;
	   }
	   s+=" "+hours+":"+minute;
	   return(s);                 
}

//将date转换成String带小时 分
function SetTimeformate4(newtime){
	  if(newtime!=null&&newtime!=""){
		  var d, s; 
		  var year; 
		  var month;
		  var daily; 
		  var houre;
		  var minute;            
		  d = new Date();           
		  d.setTime(newtime);
		  if(window.navigator.userAgent.indexOf("Firefox")>=1){
			 year=d.getYear()+1900;
			 if(d.getMonth()+1>0&&d.getMonth()+1<10){
			 	month="-0"+(d.getMonth()+1);
			 }else{
			 	month="-"+(d.getMonth()+1);
			 }
			 if(d.getDate()>0&&d.getDate()<10){
			 	daily="-0"+d.getDate();
			 }else{
			 	daily="-"+d.getDate();
			 }
		  }else if(window.navigator.userAgent.indexOf("Chrome")>=1 || BrowserType().ie == 9.0){
			 year=d.getYear()+1900;
			 if(d.getMonth()+1>0&&d.getMonth()+1<10){
			 	month="-0"+(d.getMonth()+1);
			 }else{
			 	month="-"+(d.getMonth()+1);
			 }
			 if(d.getDate()>0&&d.getDate()<10){
				daily="-0"+d.getDate();
			 }else{
			 	daily="-"+d.getDate();
			 }
		  }else{
			 year=d.getYear();
			 if(d.getMonth()+1>0&&d.getMonth()+1<10){
			 	 month="-0"+(d.getMonth()+1);
			 }else{
			 	 month="-"+(d.getMonth()+1);
			 }
			 if(d.getDate()>0&&d.getDate()<10){
				 daily="-0"+d.getDate();
			 }else{
			 	 daily="-"+d.getDate();
			 }
		  }
		  s=year+month+daily;
		  hours=d.getHours();
		  if(hours>0&&hours<10){
		   	   hours="0"+hours;
		  }
		  minute=d.getMinutes();
		  if(minute>0&&minute<10){
		   	   minute="0"+minute;
		  }
		  s+=" "+hours+":"+minute;
		  return(s);     
	  }else{
		  return "";
	  }
}

///////////////////////////////////////////////////////
// 将日期类型转换成字符串型格式yyyyMMddhhmmss
////////////////////////////////////////////////////////
function ChangeTimeToString(DateIn)
{
	var Year=0;
	var Month=0;
	var Day=0;
	var Hour = 0;
	var Minute = 0;
	var Seconds=0;
	var CurrentDate="";
	
	//初始化时间
	if(window.navigator.userAgent.indexOf("Firefox")>=1){
		 Year=DateIn.getYear()+1900;
	}else{
		 Year=DateIn.getYear();
	}
	Month     = DateIn.getMonth()+1;
	Day       = DateIn.getDate();
	Hour      = DateIn.getHours();
	Minute    = DateIn.getMinutes();
	Seconds   = DateIn.getSeconds();
	CurrentDate = Year;
	if (Month >= 10 )
	{
	    CurrentDate = CurrentDate + Month ;
	}
	else
	{
	    CurrentDate = CurrentDate + "0" + Month ;
	}
	if (Day >= 10 )
	{
	    CurrentDate = CurrentDate + Day ;
	}
	else
	{
	    CurrentDate = CurrentDate + "0" + Day ;
	}
	
	 if(Hour >=10)
	{
	    CurrentDate = CurrentDate + "" + Hour ;
	}
	else
	{
	    CurrentDate = CurrentDate + "0" + Hour ;
	}
	if(Minute >=10)
	{
	    CurrentDate = CurrentDate + "" + Minute ;
	}
	else
	{
	    CurrentDate = CurrentDate + "0" + Minute ;
	}   
	 if(Seconds >=10)
	{
	    CurrentDate = CurrentDate + "" + Seconds ;
	}
	else
	{
	    CurrentDate = CurrentDate + "0" + Seconds ;
	}
	
	return CurrentDate;
}

///////////////////////////////////////////////////////
// 将日期类型转换成字符串型格式yyyy-MM-dd-hh-mm-ss
////////////////////////////////////////////////////////
function ChangeTimeToString2(DateIn)
{
	var Year=0;
	var Month=0;
	var Day=0;
	var Hour = 0;
	var Minute = 0;
	var Seconds=0;
	var CurrentDate="";
	
	//初始化时间
	if(window.navigator.userAgent.indexOf("Firefox")>=1){
		 Year=DateIn.getYear()+1900;
	}else{
		 Year=DateIn.getYear();
	}
	Month     = DateIn.getMonth()+1;
	Day       = DateIn.getDate();
	Hour      = DateIn.getHours();
	Minute    = DateIn.getMinutes();
	Seconds   = DateIn.getSeconds();
	
	CurrentDate = Year + "";
	if (Month >= 10 )
	{
	    CurrentDate = CurrentDate +"-"+ Month + "";
	}
	else
	{
	    CurrentDate = CurrentDate + "-0" + Month + "";
	}
	if (Day >= 10 )
	{
	    CurrentDate = CurrentDate + "-"+Day ;
	}
	else
	{
	    CurrentDate = CurrentDate + "-0" + Day ;
	}
	
	 if(Hour >=10)
	{
	    CurrentDate = CurrentDate + "-" + Hour ;
	}
	else
	{
	    CurrentDate = CurrentDate + "-0" + Hour ;
	}
	if(Minute >=10)
	{
	    CurrentDate = CurrentDate + "-" + Minute ;
	}
	else
	{
	    CurrentDate = CurrentDate + "-0" + Minute ;
	}   
	 if(Seconds >=10)
	{
	    CurrentDate = CurrentDate + "-" + Seconds ;
	}
	else
	{
	    CurrentDate = CurrentDate + "-0" + Seconds ;
	}
	
	return CurrentDate;
}
///////////////////////////////////////////////////////
// 将日期类型转换成字符串型格式yyyy-MM-dd hh:mm:ss
////////////////////////////////////////////////////////
function ChangeTimeToString3(DateIn)
{
	if (DateIn == null || DateIn == "") {
			return "";
		}
	var Year=0;
	var Month=0;
	var Day=0;
	var Hour = 0;
	var Minute = 0;
	var Seconds=0;
	var CurrentDate="";
	
	//初始化时间
	if(window.navigator.userAgent.indexOf("Firefox")>=1|| BrowserType().ie == 8.0){
		 Year=DateIn.getYear();
	}else{
		 Year=DateIn.getYear();
	}
	Month     = DateIn.getMonth()+1;
	Day       = DateIn.getDate();
	Hour      = DateIn.getHours();
	Minute    = DateIn.getMinutes();
	Seconds   = DateIn.getSeconds();
	
	CurrentDate = Year + "";
	if (Month >= 10 )
	{
	    CurrentDate = CurrentDate +"-"+ Month + "";
	}
	else
	{
	    CurrentDate = CurrentDate + "-0" + Month + "";
	}
	if (Day >= 10 )
	{
	    CurrentDate = CurrentDate + "-"+Day ;
	}
	else
	{
	    CurrentDate = CurrentDate + "-0" + Day ;
	}
	
	 if(Hour >=10)
	{
	    CurrentDate = CurrentDate + " " + Hour ;
	}
	else
	{
	    CurrentDate = CurrentDate + " 0" + Hour ;
	}
	if(Minute >=10)
	{
	    CurrentDate = CurrentDate + ":" + Minute ;
	}
	else
	{
	    CurrentDate = CurrentDate + ":0" + Minute ;
	}   
	 if(Seconds >=10)
	{
	    CurrentDate = CurrentDate + ":" + Seconds ;
	}
	else
	{
	    CurrentDate = CurrentDate + ":0" + Seconds ;
	}
	
	return CurrentDate;
}

function addDate(num)
{
//可以加上错误处理
  var a = new Date()
  a = a.valueOf()
  a = a - num * 24 * 60 * 60 * 1000
  a = new Date(a)
  return a;
}


//将date转换成String 同时自动补零
	function SetTimeformateZero(newtime){
	  var year; 
	  var month;
	  var daily;                
	   d = new Date();           
	   d.setTime(newtime);
		if(window.navigator.userAgent.indexOf("Firefox")>=1){
			year = d.getYear()+1900; 
		}else if(window.navigator.userAgent.indexOf("Chrome")>=1 || BrowserType().ie == 9.0){
			year = d.getYear()+1900; 
		}else{
		   year = d.getYear();  
		}
		if(d.getMonth()+1>0&&d.getMonth()+1<10){
		 month="-0"+(d.getMonth()+1);
		 }else{
		 month="-"+(d.getMonth()+1);
		 }
		 if(d.getDate()>0&&d.getDate()<10){
		 daily="-0"+d.getDate();
		 }else{
		 daily="-"+d.getDate();
		 }
	   s=year+month+daily;
	   return(s);                 
}

//将date转换成String 同时自动补零
	function SetTimeformateZero2(newtime){
		if (newtime == null || newtime == "") {
			return "";
		}
	   var d, s; 
	  var year; 
	  var month;
	  var daily;                
	   d = new Date();           
	   d.setTime(newtime);
	   if(window.navigator.userAgent.indexOf("Firefox")>=1){
			year = d.getFullYear()+1900; 
		}else if(window.navigator.userAgent.indexOf("Chrome")>=1){
			// || BrowserType().ie == 9.0
			year = d.getFullYear()+1900; 
		}else{
		   year = d.getFullYear();  
		}
		if(d.getMonth()+1>0&&d.getMonth()+1<10){
		 month="-0"+(d.getMonth()+1);
		 }else{
		 month="-"+(d.getMonth()+1);
		 }
		 if(d.getDate()>0&&d.getDate()<10){
		 daily="-0"+d.getDate();
		 }else{
		 daily="-"+d.getDate();
		 }
	   s=year+month+daily;
	   return(s);                 
}



//将date转换成String 同时自动补零  格式为YYYY-MM
	function SetTimeformateYearMounth(newtime){
	   var d, s; 
	  var year; 
	  var month;
	  var daily;                
	   d = new Date();           
	   d.setTime(newtime);
	  if(window.navigator.userAgent.indexOf("Firefox")>=1){
		 
		 year=d.getYear()+1900;
		 
		 if(d.getMonth()+1>0&&d.getMonth()+1<10){
		 month="-0"+(d.getMonth()+1);
		 }else{
		 month="-"+(d.getMonth()+1);
		 }
		}else{
		
		  year=d.getYear();
		 if(d.getMonth()+1>0&&d.getMonth()+1<10){
		 month="-0"+(d.getMonth()+1);
		 }else{
		 month="-"+(d.getMonth()+1);
		 }
		}
	   s=year+month
	   return(s);                 
}


//将date转换成String 同时自动补零  格式为YYYY-MM
	function SetTimeformateYearMounth2(newtime){
	if (newtime == null || newtime == "") {
			return "";
		}
	   var d, s; 
	  var year; 
	  var month;
	   d = new Date();           
	   d.setTime(newtime);
	   if(window.navigator.userAgent.indexOf("Firefox")>=1){
			year = d.getFullYear()+1900; 
		}else if(window.navigator.userAgent.indexOf("Chrome")>=1){
			// || BrowserType().ie == 9.0
			year = d.getFullYear()+1900; 
		}else{
		   year = d.getFullYear();  
		}
		if(d.getMonth()+1>0&&d.getMonth()+1<10){
		 month="-0"+(d.getMonth()+1);
		 }else{
		 month="-"+(d.getMonth()+1);
		 }
	   s=year+month;
	   return(s);    
	
	              
}



//将String转换成Date
function formatDate(time){
 	  var time1 = time.split("-");
 	  if(time1.length==3){
      	var date =new Date(time1[0],(time1[1]-1),time1[2],0,0);
 	  }else if(time1.length==2){
 	    var date =new Date(time1[0],(time1[1]-1),0,0,0);
 	  }else{
 	    var date =new Date(time1[0],0,0,0,0);
 	  }
     return date;
}
//将String (yyyy-MM-dd HH:mm:ss) 转换成Date
function formatDate2(time){
 	  var strTime = time.split(" ");
 	  time1 = strTime[0].split("-");
 	  time2 = strTime[1].split(":");
 	  if(time1.length==3){
      	var date =new Date(time1[0],(time1[1]-1),time1[2],time2[0],time2[1],time2[2]);
 	  }else if(time1.length==2){
 	    var date =new Date(time1[0],(time1[1]-1),0,0,0,0);
 	  }else{
 	    var date =new Date(time1[0],0,0,0,0,0);
 	  }
     return date;
}

//validate number
function checkNumberOnly() {
	if (!(event.keyCode >= 48 && event.keyCode <= 57)) {
		event.keyCode = 0;
		return;
	}
}

//validate is num
function isNum(id) {
	var num = document.getElementById(id).value;
	if (isNaN(num)) {
		alert("\u975e\u6cd5\u6570\u5b57\uff0c\u8bf7\u91cd\u65b0\u8f93\u5165");
		document.getElementById(id).value = "";
		return false;
	} else {
		return true;
	}
}


function isNumZS(id) {
	var num = document.getElementById(id).value;
	if (isNaN(num)) {
		alert("\u975e\u6cd5\u6570\u5b57\uff0c\u8bf7\u91cd\u65b0\u8f93\u5165");
		document.getElementById(id).value = "";
		return false;
	} else {
		if(num.Trim()!=""){
		document.getElementById(id).value = parseInt(num,10);
		}
		
		return true;
	}
}

//validate is num2 传value
function isNum2(num) {
	if (isNaN(num)) {
		//alert("\u975e\u6cd5\u6570\u5b57\uff0c\u8bf7\u91cd\u65b0\u8f93\u5165");
		return false;
	} else {
		return true;
	}
}
//validate decimal fraction
function checkDecimalFraction() {
	if (!(event.keyCode >= 48 && event.keyCode <= 57) && event.keyCode != 46) {
		event.keyCode = 0;
		return;
	}
}

//validate phone number
function ismobile(id) {
	var mobile = document.getElementById(id).value;
	var myreg = /^(((13[0-9]{1})|14[0-9]{1}|15[0-9]{1}|18[0-9]{1}|013[0-9]{1}|15[0-9]{1}|18[0-9]{1})+\d{8})$/;
	var p1 = /^([0\+]\d{2,3})?(0[0-9]{2,3}[0-9]{7,8})+(-(\d{3,}))?$/;
	var me = false;
	if (p1.test(mobile)) {
		me = true;
	}
	if (me) {
		return true;
	} else {
		if (!myreg.test(mobile)) {
			if (mobile.length != 11) {
				alert("\u60a8\u6240\u8f93\u5165\u7684\u7535\u8bdd\u53f7\u7801\u6709\u8bef\uff0c\u8bf7\u91cd\u65b0\u8f93\u5165");
				document.getElementById(id).focus();
				return false;
			}
			alert("\u60a8\u6240\u8f93\u5165\u7684\u7535\u8bdd\u53f7\u7801\u6709\u8bef\uff0c\u8bf7\u91cd\u65b0\u8f93\u5165");
			document.getElementById(id).focus();
			return false;
		}
	}
	return true;
}
function ismobile2(mobile) {
	var myreg = /^((((0)?1[0-9]{2}))+\d{8})$/;
	var p1 = /^([0\+]\d{2,3})?(0[0-9]{2,3}[-_－—]?[0-9]{7,8})+(-(\d{3,}))?$/;
	var me = false;
	if (p1.test(mobile)) {
		me = true;
	}
	if (me) {
		return true;
	} else {
		if (!myreg.test(mobile)) {
			if (mobile.length != 11) {
				alert("\u60a8\u6240\u8f93\u5165\u7684\u7535\u8bdd\u53f7\u7801\u6709\u8bef\uff0c\u8bf7\u91cd\u65b0\u8f93\u5165");
				//document.getElementById(id).focus();
				return false;
			}
			alert("\u60a8\u6240\u8f93\u5165\u7684\u7535\u8bdd\u53f7\u7801\u6709\u8bef\uff0c\u8bf7\u91cd\u65b0\u8f93\u5165");
		//	document.getElementById(id).focus();
			return false;
		}
	}
	return true;
}

//validate same password
function isSamePassword(pass1, pass2) {
	if (!checkPassword(pass1)) {
		return false;
	}
	if (pass1 != pass2) {
		alert("确认密码与原密码不一致");
		return false;
	}
	return true;
}


    
//validate ID Card
function checkIdcard(idcard) {
	var area = {11:"\u5317\u4eac", 12:"\u5929\u6d25", 13:"\u6cb3\u5317", 14:"\u5c71\u897f", 15:"\u5185\u8499\u53e4", 21:"\u8fbd\u5b81", 22:"\u5409\u6797", 23:"\u9ed1\u9f99\u6c5f", 31:"\u4e0a\u6d77", 32:"\u6c5f\u82cf", 33:"\u6d59\u6c5f", 34:"\u5b89\u5fbd", 35:"\u798f\u5efa", 36:"\u6c5f\u897f", 37:"\u5c71\u4e1c", 41:"\u6cb3\u5357", 42:"\u6e56\u5317", 43:"\u6e56\u5357", 44:"\u5e7f\u4e1c", 45:"\u5e7f\u897f", 46:"\u6d77\u5357", 50:"\u91cd\u5e86", 51:"\u56db\u5ddd", 52:"\u8d35\u5dde", 53:"\u4e91\u5357", 54:"\u897f\u85cf", 61:"\u9655\u897f", 62:"\u7518\u8083", 63:"\u9752\u6d77", 64:"\u5b81\u590f", 65:"\u65b0\u7586", 71:"\u53f0\u6e7e", 81:"\u9999\u6e2f", 82:"\u6fb3\u95e8", 91:"\u56fd\u5916"};
	var idcard, Y, JYM;
	var S, M;
	var idcard_array = new Array();
	idcard_array = idcard.split("");
    //aera check
	if (area[parseInt(idcard.substr(0, 2))] == null) {
		return 4;
	}
    //number && formater
	switch (idcard.length) {
	  case 15:
		if ((parseInt(idcard.substr(6, 2)) + 1900) % 4 == 0 || ((parseInt(idcard.substr(6, 2)) + 1900) % 100 == 0 && (parseInt(idcard.substr(6, 2)) + 1900) % 4 == 0)) {
			ereg = /^[1-9][0-9]{5}[0-9]{2}((01|03|05|07|08|10|12)(0[1-9]|[1-2][0-9]|3[0-1])|(04|06|09|11)(0[1-9]|[1-2][0-9]|30)|02(0[1-9]|[1-2][0-9]))[0-9]{3}$/;//check birthday 
		} else {
			ereg = /^[1-9][0-9]{5}[0-9]{2}((01|03|05|07|08|10|12)(0[1-9]|[1-2][0-9]|3[0-1])|(04|06|09|11)(0[1-9]|[1-2][0-9]|30)|02(0[1-9]|1[0-9]|2[0-8]))[0-9]{3}$/;//check birthday
		}
		if (ereg.test(idcard)) {
			return 0;
		} else {
			return 2;
		}
		break;
	  case 18:
        //leap year:((01|03|05|07|08|10|12)(0[1-9]|[1-2][0-9]|3[0-1])|(04|06|09|11)(0[1-9]|[1-2][0-9]|30)|02(0[1-9]|[1-2][0-9]))
        //normal year:((01|03|05|07|08|10|12)(0[1-9]|[1-2][0-9]|3[0-1])|(04|06|09|11)(0[1-9]|[1-2][0-9]|30)|02(0[1-9]|1[0-9]|2[0-8]))
		if (parseInt(idcard.substr(6, 4)) % 4 == 0 || (parseInt(idcard.substr(6, 4)) % 100 == 0 && parseInt(idcard.substr(6, 4)) % 4 == 0)) {
			ereg = /^[1-9][0-9]{5}19[0-9]{2}((01|03|05|07|08|10|12)(0[1-9]|[1-2][0-9]|3[0-1])|(04|06|09|11)(0[1-9]|[1-2][0-9]|30)|02(0[1-9]|[1-2][0-9]))[0-9]{3}[0-9Xx]$/;
		} else {
			ereg = /^[1-9][0-9]{5}19[0-9]{2}((01|03|05|07|08|10|12)(0[1-9]|[1-2][0-9]|3[0-1])|(04|06|09|11)(0[1-9]|[1-2][0-9]|30)|02(0[1-9]|1[0-9]|2[0-8]))[0-9]{3}[0-9Xx]$/;
		}
		if (ereg.test(idcard)) {
			S = (parseInt(idcard_array[0]) + parseInt(idcard_array[10])) * 7 + (parseInt(idcard_array[1]) + parseInt(idcard_array[11])) * 9 + (parseInt(idcard_array[2]) + parseInt(idcard_array[12])) * 10 + (parseInt(idcard_array[3]) + parseInt(idcard_array[13])) * 5 + (parseInt(idcard_array[4]) + parseInt(idcard_array[14])) * 8 + (parseInt(idcard_array[5]) + parseInt(idcard_array[15])) * 4 + (parseInt(idcard_array[6]) + parseInt(idcard_array[16])) * 2 + parseInt(idcard_array[7]) * 1 + parseInt(idcard_array[8]) * 6 + parseInt(idcard_array[9]) * 3;
			Y = S % 11;
			M = "F";
			JYM = "10X98765432";
			M = JYM.substr(Y, 1);
			if (M == idcard_array[17]) {
				return 0;
			} else {
				return 3;
			}
		} else {
			return 2;
		}
		break;
	  default:
		return 1;
		break;
	}
}
function checkResaultID(id) {
	var idcard = document.getElementById(id).value;
	var Errors = new Array("\u9a8c\u8bc1\u901a\u8fc7!", "\u8eab\u4efd\u8bc1\u53f7\u7801\u4f4d\u6570\u4e0d\u5bf9!", "\u8eab\u4efd\u8bc1\u53f7\u7801\u51fa\u751f\u65e5\u671f\u8d85\u51fa\u8303\u56f4\u6216\u542b\u6709\u975e\u6cd5\u5b57\u7b26!", "\u8eab\u4efd\u8bc1\u53f7\u7801\u6821\u9a8c\u9519\u8bef!", "\u8eab\u4efd\u8bc1\u5730\u533a\u975e\u6cd5!");
	var result = checkIdcard(idcard);
	if (result != 0) {
		alert(Errors[result]);
		document.getElementById(id).focus();
		return false;
	}
}

//validate Email
function checkEmail(a) {
	var i = a.length;
	var temp = a.indexOf("@ ");
	var tempd = a.indexOf(". ");
	if (temp > 1) {
		if ((i - temp) > 3) {
			if ((i - tempd) > 0) {
				return true;
			}
		}
	}
	return false;
}
//验证数据是否合法
function check(array,str){
	for(var j=0;j<array.length;j++){
		var obj =document.getElementById(array[j]);
				 if(obj.value==str){
				 	alert("项目不能为空");
				 	obj.focus();
				 	return;
				 }
		}
}





//验证用户名中是否有空格
function isWhiteWpace (s){
  var whitespace = " \t\n\r";
  var i;
  for (i = 0; i < s.length; i++){  
   var c = s.charAt(i);
   if (whitespace.indexOf(c) >= 0) {return true;}
 }
return false;
}

//验证用户名是否合法
function isSsnString (ssn){
var re=/^(?!_)(?!.*?_$)[a-zA-Z0-9_]+$/i;
//var re=/^(?!_)(?!.*?_$)[a-zA-Z0-9_\u4e00-\u9fa5]+$/i;
if(re.test(ssn)){return true;}else{return false;}
}
//验证用户名
function checkUserName(ssn){
 if( ssn.length<2 || ssn.length>18 ) {
  alert("\请输入正确的用户名,用户名长度为2-18位！")
  return false;
 }
 if (isWhiteWpace(ssn)){
  alert("\请输入正确的用户名,用户名中不能包含空格！");
  return false;
 }
 if (!isSsnString(ssn)){
  alert("\    对不起，您输入用户名不正确！\n用户名应该由数字、字母、下划线且不能以下划线开头和结尾！");
  return false;
 }
return true;
}

function checkssn(gotoURL) { 
 var ssn=form_Registers.username.value.toLowerCase();  
 if (checkUserName(ssn)){    
  var open_url = gotoURL + "?username=" + ssn;    
  window.open(open_url,'','status=0,directories=0,resizable=0,toolbar=0,location=0,scrollbars=0,width=322,height=200'); 
 }
}

//验证密码
function checkPassword(ssn){

if( ssn.length<6 || ssn.length>18 ) {
  alert("\请输入正确的密码,密码长度为6-18位！")
  return false;
 }
 if (isWhiteWpace(ssn)){
  alert("\请输入正确的密码,密码中不能包含空格！");
  return false;
 }
 if (!isSsnPwd(ssn)){
  alert("\ 对不起,密码格式不正确！\n密码应该由有数字、字母组成！");
  return false;
 }
return true;

}
//验证密码的合法性
function isSsnPwd (ssn){
var re=/^[a-zA-Z0-9]+$/i;
if(re.test(ssn)){return true;}else{return false;}
}
//验证日期合法性
function checkDatewxm(time){
var re=/^(\d{4})(-{1})(\d{2})(-{1})(\d{2})( {1})(\d{2})(:{1})(\d{2})$/i; 
if(re.test(time))
{
return true;
}else{
alert("您输入的日期格式不正确");
return false;
}
}

//比较时间先后b为开始时间，e为结束时间

function checkDate(b,e){
	 var begin=b.split("-");   
     var end=e.split("-");              
     if(parseInt(begin[0],10)>parseInt(end[0],10)){
     	return false;
     }else if(parseInt(begin[0],10)<parseInt(end[0],10)){
     	return true;
     } else if(parseInt(begin[0],10)==parseInt(end[0],10)&&parseInt(begin[1],10)>parseInt(end[1],10)){
     	return false;
     }else if(parseInt(begin[0],10)==parseInt(end[0],10)&&parseInt(begin[1],10)<parseInt(end[1],10)){
     	return true;
     }else if(parseInt(begin[0],10)==parseInt(end[0],10)&&parseInt(begin[1],10)==parseInt(end[1],10)&&parseInt(begin[2],10)>parseInt(end[2],10)){
     	return false;
     }else{
		return true;     
     }
}
function checkDate2(b,e){
	if(b != "" && b != null && e != null && e != ""){
		var begin = b.split(" ");//开始时间
		 var begin1 = begin[0].split("-");
		 var begin2 = begin[1].split(":");
	     var end=e.split(" ");//结束时间
	     var end1 = end[0].split("-");
	     var end2 = end[1].split(":");
	     //yyyy
	     if(parseInt(begin1[0],10)>parseInt(end1[0],10)){
	     	return false;
	     }else if(parseInt(begin1[0],10)<parseInt(end1[0],10)){
	     	return true;
	     //yyyy-MM
	     } else if(parseInt(begin1[0],10)==parseInt(end1[0],10) && parseInt(begin1[1],10)>parseInt(end1[1],10)){
	     	return false;
	     }else if(parseInt(begin1[0],10)==parseInt(end1[0],10) && parseInt(begin1[1],10)<parseInt(end1[1],10)){
	     	return true;
	     //yyyy-MM-dd
	     }else if(parseInt(begin1[0],10)==parseInt(end1[0],10) && parseInt(begin1[1],10)==parseInt(end1[1],10) && parseInt(begin1[2],10) > parseInt(end1[2],10)){
	     	return false;
	     }else if(parseInt(begin1[0],10)==parseInt(end1[0],10) && parseInt(begin1[1],10)==parseInt(end1[1],10) && parseInt(begin1[2],10) < parseInt(end1[2],10)){
	     	return true;
	     //yyyy-MM-dd HH
	     }else if(parseInt(begin1[0],10)==parseInt(end1[0],10) && parseInt(begin1[1],10)==parseInt(end1[1],10) && parseInt(begin1[2],10) == parseInt(end1[2],10) && parseInt(begin2[0],10) > parseInt(end2[0],10)){
	     	return false;
	     }else if(parseInt(begin1[0],10)==parseInt(end1[0],10) && parseInt(begin1[1],10)==parseInt(end1[1],10) && parseInt(begin1[2],10) == parseInt(end1[2],10) && parseInt(begin2[0],10) < parseInt(end2[0],10)){
	     	return true;
	     //yyyy-MM-dd HH:mm
	     }else if(parseInt(begin1[0],10)==parseInt(end1[0],10) && parseInt(begin1[1],10)==parseInt(end1[1],10) && parseInt(begin1[2],10) == parseInt(end1[2],10) && parseInt(begin2[0],10) == parseInt(end2[0],10) && parseInt(begin2[1],10) > parseInt(end2[1],10) ){
	     	return false;
	     }else if(parseInt(begin1[0],10)==parseInt(end1[0],10) && parseInt(begin1[1],10)==parseInt(end1[1],10) && parseInt(begin1[2],10) == parseInt(end1[2],10) && parseInt(begin2[0],10) == parseInt(end2[0],10) && parseInt(begin2[1],10) < parseInt(end2[1],10)){
	     	return true;
	     //yyyy-MM-dd HH:mm:ss
	     }else if(parseInt(begin1[0],10)==parseInt(end1[0],10) && parseInt(begin1[1],10)==parseInt(end1[1],10) && parseInt(begin1[2],10) == parseInt(end1[2],10) && parseInt(begin2[0],10) == parseInt(end2[0],10) && parseInt(begin2[1],10) == parseInt(end2[1],10) && parseInt(begin2[2],10) > parseInt(end2[2],10)){
	     	return false;
	     }else{
			return true;     
	     }
	}else{
		return true;
	}
}
//加载时数据锁定页面方法① 启动保护罩
function showLoading(type,showStr) {
	//type==null||type==""
   if(showStr==null||showStr==""){
		 showStr="数据加载中......";
   }
   if(1==1){
	   parent.document.body.style.overflow = 'hidden';
	   var div=parent.document.createElement("div");
	   div.innerHTML="<div style='border:solid 1px #000;z-index:994;font-size:12px; background:#b9edfe;position:fixed; top:45%; left:45%;width:130px;padding:5px;'>&nbsp;"+
	   "<img src='"+basePath+"sources/images/loading.gif' width='16' height='16' align='absmiddle' />"+showStr+"</div>"+
	   "<div id='filltop' style='position:fixed;background-color:#8E8E8E;z-index:991;top:0px; left:0px; width:100%; height:100%;filter:alpha(opacity=50);opacity: 0.5;-moz-opacity: 0.5'></div>"; 
	   div.setAttribute("id", "page_loading");
	   parent.document.body.appendChild(div);
   }else{
	   document.body.style.overflow = 'hidden';
	   showStr="数据加载中......";
	   var div=document.createElement("div");
	   div.innerHTML="<div style='border:solid 1px #000;z-index:994;font-size:12px; background:#b9edfe;position:absolute; top:45%; left:45%;width:130px;padding:5px;'>&nbsp;"+
	   "<img src='"+basePath+"sources/images/loading.gif' width='16' height='16' align='absmiddle' />"+showStr+"</div>"+
	   "<div id='filltop' style='position:absolute;background-color:#8E8E8E;z-index:991;top:0px; left:0px; width:20000; height:20000;filter:alpha(opacity=50);opacity: 0.5;-moz-opacity: 0.5'></div>"; 
	   div.setAttribute("id", "page_loading");
	   document.body.appendChild(div);
   }
}


//加载数时据锁定页面方法② 隐藏保护罩 a：1 隐藏
function hiddenLoading(a){
	if(a==1){
		if(1==1){
			parent.document.body.style.overflow = ''; 
	   		var div =parent.document.getElementById("page_loading");
	   		if(div !==null){
	    		div.parentNode.removeChild(div);   
	    		div=null;
	    	} 
		}else{
			document.body.style.overflow = ''; 
	   		var div =document.getElementById("page_loading");
	   		if(div !==null){
	    		div.parentNode.removeChild(div);   
	    		div=null;
	    	} 
		}
	}
}

//实现Java中的trim方法
//去左右两边空格
String.prototype.Trim = function()
{
return this.replace(/(^\s*)|(\s*$)/g, "");
}

//去左边空格
String.prototype.LTrim = function()
{
return this.replace(/(^\s*)/g, "");
}
//去右边空格
String.prototype.RTrim = function()
{
return this.replace(/(\s*$)/g, "");
}


//判断 数字
function isDigit(s){
	var patrn = /^[0-9]{1,10}$/;
	if (!patrn.test(s)) {
		return false;
	}
	return true;
}


//判断是否为合法金额
function ismoney(value){
	return (/^(([1-9]\d*)|\d)(\.\d{1,2})?$/).test(value.toString());
}


String.prototype.Trim = function() {  
  var m = this.match(/^\s*(\S+(\s+\S+)*)\s*$/);  
  return (m == null) ? "" : m[1];  
}
String.prototype.isMobile = function() {  
  return (/^(?:13\d|15[89])-?\d{5}(\d{3}|\*{3})$/.test(this.Trim()));  
} 
String.prototype.isTel = function()
{
    //"兼容格式: 国家代码(2到3位)-区号(2到3位)-电话号码(7到8位)-分机号(3位)"
    //return (/^(([0\+]\d{2,3}-)?(0\d{2,3})-)?(\d{7,8})(-(\d{3,}))?$/.test(this.Trim()));
    return (/^(([0\+]\d{2,3}-)?(0\d{2,3})-)(\d{7,8})(-(\d{3,}))?$/.test(this.Trim()));
}
function check_form(xthis){
  var s_reg = "[^ ]";
  if(xthis.phone.value.match(s_reg)==null){
    alert("提醒：请输入正确的手机号码或电话号码\n\n例如:13916752109或023-86526333");
   xthis.phone.focus();
   return false;
  }
        if (xthis.phone.value.isMobile()||xthis.phone.value.isTel())  {  
            xthis.phone.value = xthis.phone.value.Trim();            
            return true;  
        } 
        else {  
            alert("提醒：请输入正确的手机号码或电话号码\n\n例如:13916752109或023-86526333"); 
            xthis.phone.focus();
            return false;        
        }
} 


//当字符串 超过长度length时 用...代替后面的数据
function getsubString(str,length){
if(str==null){
	return "";
}
	if(str.length>=length){
		return str.substr(0,parseInt(length))+"...";
				}
		return str;
}


//格式化金额
function FormatNumber(srcStr,nAfterDot)        //nAfterDot小数位数
{
	var srcStr,nAfterDot;
	var resultStr,nTen;
	srcStr = ""+parseFloat(srcStr)+"";
	strLen = srcStr.length;
	dotPos = srcStr.indexOf(".",0);
	if (dotPos == -1){
		resultStr = srcStr+".";
		for (i=0;i<nAfterDot;i++){
			resultStr = resultStr+"0";
		}
		return resultStr;
	}else{
		if ((strLen - dotPos - 1) >= nAfterDot){
			nAfter = dotPos + nAfterDot + 1;
			nTen =1;
			for(j=0;j<nAfterDot;j++){
				nTen = nTen*10;
			}
			resultStr = Math.round(parseFloat(srcStr)*nTen)/nTen;
			return resultStr;
		}else{
			resultStr = srcStr;
			for (i=0;i<(nAfterDot - strLen + dotPos + 1);i++){
				resultStr = resultStr+"0";
			}
			return resultStr;
		}
	}
}
        
        
  //保留字符串长度 不足前面补零
function FormatRetainNumber(srcStr,nAfterDot)        //nAfterDot位数
 {
		srcStr=srcStr+"";
		if(srcStr.length<nAfterDot){
	       for(var i=srcStr.length;i<nAfterDot;i++){
	      	 srcStr="0"+srcStr;
	       }
	   }
	   return srcStr;
} 

//获取select 选择的文本
function getSelectText(elementId){
	var ddl = document.getElementById(elementId); 
	var index = ddl.selectedIndex; 
	var text = ddl.options[index].text;
	return text;
}

//关闭弹出窗口
function cancel(){
	window.opener=null;window.close();
}


function accDiv(arg1,arg2){ 
	 var t1=0,t2=0,r1,r2; 
	 try{t1=arg1.toString().split(".")[1].length}catch(e){} 
	 try{t2=arg2.toString().split(".")[1].length}catch(e){} 
	 with(Math){ 
	 r1=Number(arg1.toString().replace(".","")) 
	 r2=Number(arg2.toString().replace(".","")) 
	 return (r1/r2)*pow(10,t2-t1); 
	 } 
	 } 
	 //给Number类型增加一个div方法，调用起来更加方便。 
	 Number.prototype.div = function (arg){ 
	 return accDiv(this, arg); 
	 } 
	 //乘法函数，用来得到精确的乘法结果 
	 //说明：javascript的乘法结果会有误差，在两个浮点数相乘的时候会比较明显。这个函数返回较为精确的乘法结果。 
	 //调用：accMul(arg1,arg2) 
	 //返回值：arg1乘以arg2的精确结果 
	 function accMul(arg1,arg2) 
	 { 
	 var m=0,s1=arg1.toString(),s2=arg2.toString(); 
	 try{m+=s1.split(".")[1].length}catch(e){} 
	 try{m+=s2.split(".")[1].length}catch(e){} 
	 return Number(s1.replace(".",""))*Number(s2.replace(".",""))/Math.pow(10,m) 
	 } 
	 //给Number类型增加一个mul方法，调用起来更加方便。 
	 Number.prototype.mul = function (arg){ 
	 return accMul(arg, this); 
	 } 
	 //加法函数，用来得到精确的加法结果 
	 //说明：javascript的加法结果会有误差，在两个浮点数相加的时候会比较明显。这个函数返回较为精确的加法结果。 
	 //调用：accAdd(arg1,arg2) 
	 //返回值：arg1加上arg2的精确结果 
	 function accAdd(arg1,arg2){ 
	 var r1,r2,m; 
	 try{r1=arg1.toString().split(".")[1].length}catch(e){r1=0} 
	 try{r2=arg2.toString().split(".")[1].length}catch(e){r2=0} 
	 m=Math.pow(10,Math.max(r1,r2)) 
	 return (arg1*m+arg2*m)/m 
	 } 
	 //给Number类型增加一个add方法，调用起来更加方便。 
	 Number.prototype.add = function (arg){ 
	 return accAdd(arg,this); 
	 }
	 function Subtr(arg1,arg2){
	      var r1,r2,m,n;
	      try{r1=arg1.toString().split(".")[1].length}catch(e){r1=0}
	      try{r2=arg2.toString().split(".")[1].length}catch(e){r2=0}
	      m=Math.pow(10,Math.max(r1,r2));
	      //last modify by deeka
	      //动态控制精度长度
	      n=(r1>=r2)?r1:r2;
	      return ((arg1*m-arg2*m)/m).toFixed(n);
	 }
	 Number.prototype.subtr = function (arg){ 
		 return Subtr(this,arg); 
	}
	
	
	

/**
 * 判断传进来的数据中是否有null（用于对象.的方式）
 * data	第一个对象  data[i]
 * str  从第二个开始的对象，以字符串类型传入
 * 例如：
 * 		要显示的值为 data[i].finishedprdInfo.pfpiName，
 *		方法使用应该是：isNull(data[i],"finishedprdInfo.pfpiName")
 * 注意：isNull2(data[i],"finishedprdInfo.pfpiName","--")中，第一个参数必须传data[i]，不能传data[i].finishedprdInfo
 */
function isNull(data, str){ 
	if (data == null || typeof(data) == "undefined") {
		return "";
	}
	var array = new Array();
	var temp = "data.";
	if(str.indexOf("\.") != -1){
		array = str.split("\.");
	} else {
		array[0] = str;
	}
	var length = array.length;
	for(var i = 0; i < length; i++){
		temp += array[i];
		if(eval(temp) == null){
			return "";
		}
		if((i+1) < length){
			temp += '.';
		}
	}
	return eval(temp);
}

/**
 * 判断传进来的数据中是否有null（用于对象.的方式）
 * data	第一个对象  data[i]
 * str  从第二个开始的对象，以字符串类型传入
 * message	当为空时要显示的字符串
 * 例如：
 * 		要显示的值为 data[i].finishedprdInfo.pfpiName，当产品或者产品名称为空时显示 --
 *		使用方式应该是：isNull2(data[i],"finishedprdInfo.pfpiName","--")
 * 注意：isNull2(data[i],"finishedprdInfo.pfpiName","--")中，第一个参数必须传data[i]，不能传data[i].finishedprdInfo
 */
function isNull2(data, str, message){
	if (data == null || typeof(data) == "undefined") {
		return message;
	}
	var array = new Array();
	var temp = "data.";
	if(str.indexOf("\.") != -1){
		array = str.split("\.");
	} else {
		array[0] = str;
	}
	var length = array.length;
	for(var i = 0; i < length; i++){
		temp += array[i];
		if(eval(temp) == null){
			return message;
		}
		if((i+1) < length){
			temp += '.';
		}
	}
	return eval(temp);
}

function isNull2Trim(data, str, message){
	var returnStr = isNull2(data, str, message);
	if(returnStr!=null&&returnStr.Trim()==""){
		return message;
	}else{
		return returnStr;
	}
}


function isNull3(data,str){
	if(data==null){
		return str;
	}else{
		return data;
	}
}

function isNull3Trim(data,str){
	var returnStr = isNull3(data,str);
	if(returnStr!=null&&returnStr.Trim()==""){
		return str;
	}else{
		return returnStr;
	}
}


//判断浏览器类型
//返回类型说明  Sys.ie是获取到的是浏览器的版本号
//使用方法：Browser.ie/firefox/chrom/opera等
function BrowserType(){
	var Sys = {};
	var ua = navigator.userAgent.toLowerCase();
	var s;
	(s = ua.match(/msie ([\d.]+)/)) ? Sys.ie = s[1] :	//ie
	(s = ua.match(/firefox\/([\d.]+)/)) ? Sys.firefox = s[1] :	//火狐
	(s = ua.match(/chrome\/([\d.]+)/)) ? Sys.chrome = s[1] :	//谷歌
	(s = ua.match(/opera.([\d.]+)/)) ? Sys.opera = s[1] :	//opera
	(s = ua.match(/version\/([\d.]+).*safari/)) ? Sys.safari = s[1] : 0;
	return Sys;
}

/*
 * open出的窗口居中，只能弹出一个
 * url：URL
 * name：页面title名称
 * iWidth：宽
 * iHeight：高
 * 注意：使用此方法时，需要在使用页面的js中添加全局变量：
 *			var POP_UP_WIN = null;	//弹出窗口用，判断是否弹出过窗口
 */
var POP_UP_WIN;
function openwindow(url,name,iWidth,iHeight)
{
	if(POP_UP_WIN){	//判断是否弹出过窗口
		if(!POP_UP_WIN.closed){ 
			POP_UP_WIN.close(); 
		}
　　} 
    var url;                             //转向网页的地址;
    var name;                            //网页名称，可为空;
    var iWidth;                          //弹出窗口的宽度;
    var iHeight;                         //弹出窗口的高度;
    //获得窗口的垂直位置
    var iTop = (window.screen.availHeight-30-iHeight)/2;        
    //获得窗口的水平位置
    var iLeft = (window.screen.availWidth-10-iWidth)/2;     
    POP_UP_WIN = window.open(url,name,'height='+iHeight+',innerHeight='+iHeight+',width='+iWidth+',innerWidth='+iWidth+',top='+iTop+',left='+iLeft+',status=no,toolbar=no,menubar=no,location=no,resizable=yes,scrollbars=1,titlebar=yes');
}

function  handleTel(tel){
	if(tel==null||tel==""){
		return "";
	}
	var size = tel.length;
	var pingjun=Math.floor(size/3);
	var yushu=size%3;
	var qian=pingjun,zhong=pingjun,hou=pingjun;
	if(yushu>0){
	    hou+=1;
	}
	var qianStr=tel.substring(0,qian);
	var zhongStr="";
	for(var i=0;i<zhong;i++){
	    zhongStr+="*";
	}
	var houStr=tel.substring(size-hou,size);
	return qianStr+zhongStr+houStr;
	
}

/*
 *  方法:Array.remove(dx)
 *  功能:根据元素值删除数组元素.
 *  参数:元素值
 *  返回:在原数组上修改数组
 */
Array.prototype.indexOf = function (val) {
	for (var i = 0; i < this.length; i++) {
		if (this[i] == val) {
			return i;
		}
	}
	return -1;
};

Array.prototype.removevalue = function (val) {
	var index = this.indexOf(val);
	if (index > -1) {
		this.splice(index, 1);
	}
};


/*
 *  方法:Array.remove(dx)
 *  功能:根据元素位置值删除数组元素.
 *  参数:元素值
 *  返回:在原数组上修改数组
 */
Array.prototype.remove = function (dx) {
	if (isNaN(dx) || dx > this.length) {
		return false;
	}
	for (var i = 0, n = 0; i < this.length; i++) {
		if (this[i] != this[dx]) {
			this[n++] = this[i];
		}
	}
	this.length -= 1;
};

/**
 * 功能：输入框只能输入数字
 * obj：文本框对象
 * type：类型，1---只能输入大于0整数，2---只能输入大于等于0的数字(包括小数)
 				3---只能输入大于等于0整数
 */
function c_inputCheck(obj, type){
	var input = obj.value.Trim();
	switch (type) {
	case 1: {
		if(obj.value.length==1){
			obj.value=obj.value.replace(/[^1-9]/g,'');
		} else {
			obj.value=obj.value.replace(/\D/g,'');
		}
		break;
	}
	case 2: {
		obj.value = obj.value.replace(/[^\d.]/g,""); 
		//必须保证第一位为数字而不是. 
		obj.value = obj.value.replace(/^\./g,""); 
		//保证只有出现一个.而没有多个. 
		obj.value = obj.value.replace(/\.{2,}/g,"."); 
		//保证.只出现一次，而不能出现两次以上 
		obj.value = obj.value.replace(".","$#$").replace(/\./g,"").replace("$#$",".");
		break;
	}
	case 3: {
		if(obj.value.length==1){
			obj.value=obj.value.replace(/[^0-9]/g,'');
		} else {
			obj.value=obj.value.replace(/\D/g,'');
		}
		break;
	}
	case 4: {
		if(isNaN(input)){
			obj.value="";
		}
		break;
	}
	}
}
//隔行换色
function showcolor(id){ //table的id
	var color1 = "#ffffff" 
	var color2 = "#CAE1F9"; 
	var trs = document.getElementById(id).getElementsByTagName("tr"); 
	for (var i=0;i<trs.length;i++){ 
		if (i%2==0) { 
			trs[i].style.backgroundColor=color1; //隔行换色
			trs[i].onmouseout = function(){ 
				this.style.backgroundColor = color1; 
			}
		} else { 
			trs[i].style.backgroundColor=color2; //隔行换色
			trs[i].onmouseout = function(){ 
				this.style.backgroundColor = color2; 
			}
		}
	}
}
//查询登录人所在的机构（部门，车间）
function selOrgInfo(orgId,orgList){
	var len = orgList.length;
	var b = false;
	for(var i = 0 ; i < len ; i ++){
		if(orgId==orgList[i].id){
			b = true;
		}
	}
	return b;
}

//将滚动条滚动到最底端 
function myScroll() 
{ 
//前边是获取chrome等一般浏览器 如果获取不到就是ie了 就用ie的办法获取 
var x=document.body.scrollTop||document.documentElement.scrollTop; 
var timer=setInterval(function(){ 
x=x-1000; 
if(x<1000) 
{ 
x=0; 
window.scrollTo(x,x); 
clearInterval(timer); 
} 
window.scrollTo(x,x); 
},"100"); 
}
//日期加天数,显示计算后的日期,@param sdate=日期 days=天数
function DateAdd(sdate, days) {
    var a = new Date(sdate);
    a = a.valueOf();
    a = a + days * 24 * 60 * 60 * 1000;
    a = new Date(a);
    return SetTimeformateZero2(a);
} 